const store = new Vuex.Store({
  state: {
    scrollDistance: 0,
    screenHeight: window.innerHeight,
    price: 0,
    num: 0
  },
  getters: {
    pageHeight (state) {
      return state.scrollDistance + state.screenHeight
    }
  },
  mutations: {
    scrollEvent (state) {
      state.scrollDistance = document.documentElement.scrollTop
    },
    changePrice (state, [target, flag]) {
      state.price = state.price + target;
      flag == 'on' ? target > 0 ? state.num++ : state.num-- : ''
    }
  }
})

export default store